package edu.infomatik.tundra.model;

import org.apache.tapestry5.ValueEncoder;

import edu.infomatik.tundra.data.DAOtundra;
import edu.infomatik.tundra.logic.UStoryBean;

public class StoryIdEncoder implements ValueEncoder<UStoryBean> {
	
	@Override
	public String toClient(UStoryBean value) {
		return ""+value.getId();
	}

	@Override
	public UStoryBean toValue(String clientValue) {
		if (null!=clientValue){
			UStoryBean wb = new UStoryBean();
			wb.setId(Long.parseLong(clientValue));
			return (UStoryBean)DAOtundra.getInstance().getBeanById(wb);
		}
		return new UStoryBean();
	}

}
